<!-- 课程类型表单弹窗 -->
<form id="courseUser-form" lay-filter="courseUser-form" class="layui-form model-form">
    <input id="id" name="id" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label">课程名称</label>
        <div class="layui-input-block">
            <input id="courseTitle" name="courseTitle" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" readonly/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">选课人</label>
        <div class="layui-input-block">
            <input id="choiceName" name="choiceName" type="text" class="layui-input" maxlength="20"
                   lay-verify="required" readonly/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block selectUp">
            <select name="state" id="state" lay-filter="state">
                <option value="1">审核中</option>
                <option value="2">通过</option>
                <option value="3">不过</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item model-form-footer">
        <button class="layui-btn layui-btn-primary" ew-event="closeDialog" type="button">取消</button>
        <button class="layui-btn" lay-filter="courseUser-form-submit" lay-submit>保存</button>
    </div>
</form>

<script>
    layui.use(['layer', 'admin', 'form'], function () {

        var layer = layui.layer;
        var admin = layui.admin;
        var form = layui.form;

        form.render();
        var courseUser = admin.getTempData('courseUser');
        if (courseUser) {
            form.val('courseUser-form', courseUser);
        }
        // 表单提交事件
        form.on('submit(courseUser-form-submit)', function (data) {
            layer.load(2);
            // debugger;
            admin.req('api-course/courseUser/update', JSON.stringify(data.field), function (data) {
                layer.closeAll('loading');
                if (data.code == 0) {
                    layer.msg(data.msg, {icon: 1, time: 2000});
                    admin.finishPopupCenter();
                } else {
                    layer.msg(data.msg, {icon: 2, time: 2000});
                }
            }, 'POST');
            return false;
        });
    });
</script>